/*
 * This file (AxActuator.java) is protected by the GNU GPL licence (v2). 
 * Please read the license.txt attached for further informations. 
 * 
 */

package artx.objects;

import java.util.Hashtable;

/**
 * Basic actuator, able to modify an Artspace.
 * 
 * @author Xavier Gouchet
 * 
 */
public abstract class AxActuator extends AxObject {

	/**
	 * the list of (name,type) of required values/params for the actuator to run
	 * properly.
	 */
	protected Hashtable<String, String> REQUIREMENTS;
	
	/**
	 * Standard Constructor.
	 * 
	 * @param id
	 *            the object's id
	 * @param name
	 *            the object's name
	 * @param requirements
	 *            the actuator's requirements
	 */
	public AxActuator(int id, String name, String[] requirements) {
		super(id, name);
		if ((requirements == null)||(requirements.length == 0)||(requirements.length%2 == 1)){
			this.REQUIREMENTS = null;
		}else{
			this.REQUIREMENTS = new Hashtable<String, String>();
			for (int i=0; i<requirements.length; i+= 2){
				String n = requirements[i];
				String t = requirements[i+1];
				this.REQUIREMENTS.put(n, t);
			}
		}
	}

	/**
	 * Apply the actuator on the artspace.
	 * 
	 * @param a
	 *            the artspace on which the actuator is applied
	 * @return boolean whether the method has been completed successfully or not
	 */
	public abstract boolean Apply(AxArtspace a);

}
